package com.pets.web.controller.admin;


import com.pets.common.core.controller.BaseController;
import com.pets.common.core.domain.AjaxResult;
import com.pets.common.core.page.TableDataInfo;
import com.pets.web.entity.PetsComment;
import com.pets.web.entity.PetsShop;
import com.pets.web.service.IPetsCommentService;
import com.pets.web.service.IPetsShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品评论表 前端控制器
 * </p>
 *
 * @author zhurenwang
 * @since 2024-05-26
 */
@RestController
@RequestMapping("/comment")
public class PetsCommentController extends BaseController {

    @Autowired
    private IPetsCommentService petsCommentService;

    @GetMapping("/list")
    public TableDataInfo list(PetsComment petsComment){
        startPage();
        List<PetsComment> list = petsCommentService.list(petsComment);
        return getDataTable(list);
    }

    @PostMapping()
    public AjaxResult add(@RequestBody PetsComment petsComment){
        return success(petsCommentService.add(petsComment));
    }

    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        return success(petsCommentService.deleteById(id));
    }

    @GetMapping("/{id}")
    public AjaxResult get(@PathVariable Integer id){
        return success(petsCommentService.getById(id));
    }

    @PutMapping()
    public AjaxResult edit(@RequestBody PetsComment petsComment){
        return success(petsCommentService.updateById(petsComment));
    }

    @GetMapping("/top/{id}")
    public AjaxResult top(@PathVariable Integer id){
        return success(petsCommentService.top(id));
    }

    @GetMapping("/audit/{id}")
    public AjaxResult audit(@PathVariable Integer id){
        return success(petsCommentService.audit(id));
    }

}
